package com.huangge1199.codewars;

/**
 * @ClassName DRoot
 * @Description TODO
 * @Author huangge1199
 * @Date 2021/10/8 16:03
 **/
public class DRoot {
    public static int digital_root(int n) {
        int sum = n;
        do {
            n = sum;
            sum = 0;
            while (n >= 10) {
                sum += n % 10;
                n /= 10;
            }
            sum += n;
        } while (sum >= 10);
        return sum;
    }
}
